/**
 * 
 */
package com.idea.auction.service;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import com.idea.auction.model.Commodity;
import com.idea.auction.model.RolePer;
import com.jfinal.aop.Before;
import com.jfinal.kit.StrKit;
import com.jfinal.plugin.activerecord.Page;
import com.jfinal.plugin.activerecord.tx.Tx;
import com.jfinal.plugin.ehcache.CacheKit;
import com.jfinal.server.BaseService;

/**
 * @author y.z
 */
public class CommodityService extends BaseService<Commodity> {
	
	/**
	 * 获取分页
	 * @param curPage
	 * @return
	 */
	public Page<Commodity> getPage(int curPage,String commodityName){
		String sql= " from commodity where 1=1 ";
		
		if(!StrKit.isBlank(commodityName)){
			sql += " and commodity_name like '%"+commodityName+"%' ";
		}
		
		return super.getPage(curPage, "select *", sql+ "  order by create_date desc ");
	}
	
	/**
	 * 删除商品
	 * @param id
	 * @return
	 */
	public boolean delete(String id){
		return super.delById(id);
	}
	
	/**
	 * 添加商品
	 * @param Commodity
	 * @return
	 */
	public boolean add(Commodity commodity){
		return super.save(commodity);
	}
	
	/**
	 * 修改商品
	 * @param Commodity
	 * @return
	 */
	public boolean update(Commodity commodity){
		return super.update(commodity);
	}
	
	/**
	 * 根据id获取详细
	 * @param id
	 * @return
	 */
	public Commodity getCommodityById(String id){
		return super.findById(id);
	}
	
}
